package com.blockchain.securewallet.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import com.blockchain.securewallet.R;
import com.blockchain.securewallet.WalletApp;
import com.blockchain.securewallet.adapter.WordsAdapter;
import com.blockchain.securewallet.base.BaseActivity;
import com.blockchain.securewallet.popup.PopupSeedQRCode;
import com.blockchain.securewallet.tools.SpaceItemDecoration;
import com.blockchain.securewallet.utils.UIHelper;

import java.util.Arrays;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class WatchSeedActivity extends BaseActivity {

    @BindView(R.id.tv_title)
    TextView tvTitle;

    @BindView(R.id.rv_seed_words)
    RecyclerView rvWords;

    private WordsAdapter adapter;
    String words;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_watch_seed);
        ButterKnife.bind(this);
        tvTitle.setText(R.string.watch_seed);

        words = WalletApp.getInstance().getWordsList();

        adapter = new WordsAdapter(this, Arrays.asList(words.split("\\s+")));
        rvWords.setLayoutManager(new GridLayoutManager(this, 3));
        rvWords.addItemDecoration(new SpaceItemDecoration(UIHelper.dipToPx(1.0f)));
        rvWords.setAdapter(adapter);
    }

    @OnClick(R.id.btn_back)
    void back() {
        finish();
    }

    @OnClick(R.id.btn_watch_seed)
    void watchSeedQrCode() {
        /*Intent intent = new Intent();
        intent.setClass(this,SeedQrCodeActivity.class);
        intent.putExtra(SeedQrCodeActivity.KEY_WORDS,words);
        startActivity(intent);*/

        PopupSeedQRCode popupSeed = new PopupSeedQRCode(WatchSeedActivity.this, words);
        popupSeed.showPopupWindow();
    }

}
